import request from '@neu/biz-core/utils/request'
import qs from 'qs'// 引入qs

export function login(data) {
  return request({
    url: '/login',
    method: 'post',
    data
  })
}

export function getInfo(token) {
  return request({
    url: '/auth/api/w/auth/users/me',
    method: 'get'
  })
}

export function logout() {
  return request({
    url: '/logout',
    method: 'post'
  })
}

export const list = () => {
  return request({
    url: '/auth/api/w/auth/users',
    method: 'get'
  })
}

export const page = (params) => {
  return request({
    url: '/auth/api/w/auth/users/p',
    params,
    method: 'get'
  })
}

export const create = (data) => {
  return request({
    url: '/auth/api/w/auth/users',
    data,
    method: 'post'
  })
}

export const remove = (id) => {
  return request({
    url: '/auth/api/w/auth/users/' + id,
    method: 'delete'
  })
}

export const detail = (id) => {
  return request({
    url: '/auth/api/w/auth/users/' + id,
    method: 'get'
  })
}

export const update = (id, data) => {
  return request({
    url: '/auth/api/w/auth/users/' + id,
    data,
    method: 'put'
  })
}

export const changepassword = (data) => {
  return request({
    url: '/auth/api/w/auth/users/changepassword',
    data: qs.stringify(data),
    method: 'put'
  })
}

export const oauth2login = (code) => {
  return request({
    url: '/oauth2login',
    params: { code },
    method: 'get'
  })
}

export const getOAuth2Config = () => {
  return request({
    url: '/auth/api/w/auth/oauth2',
    method: 'get'
  })
}
